package cn.westv.scps.domain;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.GenericGenerator;

/**
 * Created by Administrator on 2017/08/09.
 */
@Entity(name = "sys_message")
// @Table(name = "sys_message", schema = "scps", catalog = "")
public class SysMessageEntity implements Serializable {
	private String sysMessageId;
	private String title;
	private String payload;
	private String redirectUrl;
	private String content;
	private Integer contentIsEmpty;
	private Integer state;
	private Date createTime;
	private String code;

	private Set<SysMassageSendRecordEntity> sysMassageSendRecordEntitys;

	@Id
	@Column(name = "sys_message_id", nullable = false, length = 32)
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	public String getSysMessageId() {
		return sysMessageId;
	}

	public void setSysMessageId(String sysMessageId) {
		this.sysMessageId = sysMessageId;
	}

	public String getTitle() {
		return title;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getPayload() {
		return payload;
	}

	public void setPayload(String payload) {
		this.payload = payload;
	}

	@Basic
	@Column(name = "redirect_url", nullable = true, length = 256)
	public String getRedirectUrl() {
		return redirectUrl;
	}

	public void setRedirectUrl(String redirectUrl) {
		this.redirectUrl = redirectUrl;
	}

	@Basic
	@Column(name = "content", nullable = true, length = -1)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Basic
	@Column(name = "content_is_empty", nullable = true)
	public Integer getContentIsEmpty() {
		return contentIsEmpty;
	}

	public void setContentIsEmpty(Integer contentIsEmpty) {
		this.contentIsEmpty = contentIsEmpty;
	}

	@Basic
	@Column(name = "state", nullable = true)
	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	@Basic
	@Column(name = "create_time", nullable = true)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "record_id")
	public Set<SysMassageSendRecordEntity> getSysMassageSendRecordEntitys() {
		return sysMassageSendRecordEntitys;
	}

	public void setSysMassageSendRecordEntitys(Set<SysMassageSendRecordEntity> sysMassageSendRecordEntitys) {
		this.sysMassageSendRecordEntitys = sysMassageSendRecordEntitys;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		SysMessageEntity that = (SysMessageEntity) o;

		if (sysMessageId != null ? !sysMessageId.equals(that.sysMessageId) : that.sysMessageId != null)
			return false;
		if (redirectUrl != null ? !redirectUrl.equals(that.redirectUrl) : that.redirectUrl != null)
			return false;
		if (content != null ? !content.equals(that.content) : that.content != null)
			return false;
		if (contentIsEmpty != null ? !contentIsEmpty.equals(that.contentIsEmpty) : that.contentIsEmpty != null)
			return false;
		if (state != null ? !state.equals(that.state) : that.state != null)
			return false;
		if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null)
			return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = sysMessageId != null ? sysMessageId.hashCode() : 0;
		result = 31 * result + (redirectUrl != null ? redirectUrl.hashCode() : 0);
		result = 31 * result + (content != null ? content.hashCode() : 0);
		result = 31 * result + (contentIsEmpty != null ? contentIsEmpty.hashCode() : 0);
		result = 31 * result + (state != null ? state.hashCode() : 0);
		result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
		return result;
	}
}
